package com.jp.knowledge.adapter;

import android.content.Context;
import android.view.View;

import com.google.gson.JsonObject;
import com.jp.knowledge.R;
import com.jp.knowledge.http.HttpHelper;
import com.jp.knowledge.model.HeadLineData;
import com.jp.knowledge.model.IModel;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Locale;

/**
 * Created by 528787067@qq.com on 2017/1/19.
 */

public class CollectionCommtemAdapter extends CommtemAdapter {

	private DateFormat dateFormat;
	private DeleteIconClickListener deleteIconClickListener;

	public CollectionCommtemAdapter(Context context, List infos) {
		super(context, infos);
		dateFormat = new SimpleDateFormat("MM月dd日 hh:mm", Locale.getDefault());
	}

	@Override
	protected void renderData(JPRecycleViewHolder holder, Object item, int position) {
		super.renderData(holder, item, position);
		holder.getView(R.id.icon_collection).setVisibility(View.GONE);
		holder.getView(R.id.type).setVisibility(View.GONE);
		holder.getView(R.id.navType).setVisibility(View.GONE);
		holder.setText(R.id.time, dateFormat.format(((HeadLineData) item).getCreatetime()));
	}

	@Override
	protected void deleteIconClick(View view) {
		if (deleteIconClickListener != null)
			deleteIconClickListener.onDelectIconClick((int) view.getTag());
	}

	public void setDeleteIconClickListener(DeleteIconClickListener deleteIconClickListener) {
		this.deleteIconClickListener = deleteIconClickListener;
	}

	public interface DeleteIconClickListener {
		void onDelectIconClick(int position);
	}
}
